'\" te
.\" Copyright (c) 2009, Sun Microsystems, Inc.  All Rights Reserved.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.
.\"  See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with
.\" the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH PROCESSOR_BIND 2 "Dec 27, 2015"
.SH NAME
processor_bind \- bind LWPs to a processor
.SH SYNOPSIS
.LP
.nf
#include <sys/types.h>
#include <sys/processor.h>
#include <sys/procset.h>

\fBint\fR \fBprocessor_bind\fR(\fBidtype_t\fR \fIidtype\fR, \fBid_t\fR \fIid\fR, \fBprocessorid_t\fR \fIprocessorid\fR,
     \fBprocessorid_t *\fR\fIobind\fR);
.fi

.SH DESCRIPTION
.LP
The \fBprocessor_bind()\fR function binds the LWP (lightweight process) or set
of LWPs specified by \fIidtype\fR and \fIid\fR to the processor specified by
\fIprocessorid\fR. If \fIobind\fR is not \fINULL\fR, this function also sets
the \fBprocessorid_t\fR variable pointed to by \fIobind\fR to the previous
binding of one of the specified LWPs, or to \fBPBIND_NONE\fR if the selected
LWP was not bound.
.sp
.LP
If \fIidtype\fR is \fBP_PID\fR, the binding affects all LWPs of the process
with process ID (PID) \fIid\fR.
.sp
.LP
If \fIidtype\fR is \fBP_LWPID\fR, the binding affects the LWP of the current
process with LWP ID \fIid\fR.
.sp
.LP
If \fIidtype\fR is \fBP_TASKID\fR, the binding affects all LWPs of all
processes with task ID \fIid\fR.
.sp
.LP
If \fIidtype\fR is \fBP_PROJID\fR, the binding affects all LWPs of all
processes with project ID \fIid\fR.
.sp
.LP
If \fIidtype\fR is \fBP_CTID\fR, the binding affects all LWPs of all processes
with process contract ID \fIid\fR.
.sp
.LP
If \fIidtype\fR is \fBP_ZONEID\fR, the binding affects all LWPs of all
processes with zone ID \fIid\fR.
.sp
.LP
If \fIid\fR is \fBP_MYID\fR, the specified LWP, process, task, or project is
the current one.
.sp
.LP
If \fIprocessorid\fR is \fBPBIND_NONE\fR, the processor bindings of the
specified LWPs are cleared.
.sp
.LP
If \fIprocessorid\fR is \fBPBIND_QUERY\fR, the processor bindings are not
changed.
.sp
.LP
The {\fBPRIV_PROC_OWNER\fR} privilege must be asserted in the effective set of
the calling process or the real or effective user ID of the calling process
must match the real or effective user ID of the \fBLWP\fRs being bound.  If the
calling process does not have permission to change all of the specified LWPs,
the bindings of the LWPs for which it does have permission will be changed even
though an error is returned.
.sp
.LP
Processor bindings are inherited across \fBfork\fR(2) and \fBexec\fR(2).
.SH RETURN VALUES
.LP
Upon successful completion, \fB0\fR is returned.  Otherwise, \fB\(mi1\fR is
returned and  \fBerrno\fR is set to indicate the error.
.SH ERRORS
.LP
The \fBprocessor_bind()\fR function will fail if:
.sp
.ne 2
.na
\fB\fBEFAULT\fR\fR
.ad
.RS 11n
The location pointed to by \fIobind\fR was not \fINULL\fR and not writable by
the user.
.RE

.sp
.ne 2
.na
\fB\fBEINVAL\fR\fR
.ad
.RS 11n
The processor is not on-line.
.sp
The LWP is bound to a processor set or resource pool for which the
processor is not a member.
.sp
The \fIidtype\fR argument is not \fBP_PID\fR, \fBP_LWPID\fR,
\fBP_PROJID\fR, \fBP_TASKID\fR, \fBP_CTID\fR, or \fBP_ZONEID\fR.
.RE

.sp
.ne 2
.na
\fB\fBENOTSUP\fR\fR
.ad
.RS 11n
Binding a system process to a processor set is not supported.
.RE

.sp
.ne 2
.na
\fB\fBEPERM\fR\fR
.ad
.RS 11n
The {\fBPRIV_PROC_OWNER\fR} privilege is not asserted in the effective set of
the calling process and its real or effective user ID does not match the real
or effective user \fBID\fR of one of the \fBLWP\fRs being bound.
.RE

.sp
.ne 2
.na
\fB\fBESRCH\fR\fR
.ad
.RS 11n
No processes, \fBLWP\fRs, or tasks were found to match the criteria specified
by \fIidtype\fR and \fIid\fR.
.RE

.SH ATTRIBUTES
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
Interface Stability	Committed
_
MT-Level	Async-Signal-Safe
.TE

.SH SEE ALSO
.BR exec (2),
.BR fork (2),
.BR p_online (2),
.BR pset_bind (2),
.BR sysconf (3C),
.BR process (5),
.BR project (5),
.BR attributes (7),
.BR privileges (7),
.BR pooladm (8),
.BR psradm (8),
.BR psrinfo (8),
.BR zoneadm (8)
